from sqlalchemy import Column, ForeignKey, Date
from sqlalchemy.orm import relationship
from sqlalchemy.dialects.oracle import VARCHAR2, NUMBER
from app.db.base import Base
from app.models.iaro_career.personal_eval import PersonalEvaluationResponse


# Scholar Entity
class Scholar(Base):
    __tablename__ = 'SCHOLARS'
    __table_args__ = {'schema': 'IARO_CAREER'}

    scholar_id           = Column(VARCHAR2(4000), primary_key=True)
    program_id           = Column(VARCHAR2(50))
    status_id            = Column(NUMBER, ForeignKey('IARO_CAREER.SCHOLAR_STATUS.status_id'))
    student_id           = Column(VARCHAR2(20))
    first_name           = Column(VARCHAR2(100))
    last_name            = Column(VARCHAR2(100))
    preferred_name       = Column(VARCHAR2(100))
    gender               = Column(VARCHAR2(1))
    date_of_birth        = Column(Date)
    school_code          = Column(VARCHAR2(100))
    dietary_pref_id      = Column(NUMBER, ForeignKey('IARO_CAREER.DIETARY_PREFERENCES.dietary_pref_id'))
    dietary_allergy      = Column(VARCHAR2(4000))
    dietary_religious    = Column(VARCHAR2(4000))
    medical_allergies    = Column(VARCHAR2(4000))
    email                = Column(VARCHAR2(1000))
    program_start_date   = Column(Date)
    program_finish_date  = Column(Date)
    current_email        = Column(VARCHAR2(1000))

    # Relationships
    status               = relationship("ScholarStatus", back_populates="scholars")
    dietary_preference   = relationship("DietaryPreferences", back_populates="scholars")
    ite_details          = relationship("ITEDetail", back_populates="scholar")
    personal_responses   = relationship("PersonalEvaluationResponse", back_populates="scholar")














